<?php
/*
 * 用户操作日志
 */
namespace app\admin\controller;
use app\common\controller\AdminBase;
use think\facade\Db;
use app\common\model\UserLog as UserLogModel;

class UserLog extends AdminBase
{
    protected function _initialize()
    {
        parent::_initialize();
    }
    //日志列表
    public function lists()
    {
        $param = $this->request->param();
        if (!empty($param['title'])) {
            $where = function ($query) use ($param){$query->where('name|mobile','LIKE', '%'.trim($param['title']).'%');};
        }else{
           $where = 1;
        }
        $list = UserLogModel::hasWhere('user',$where)->with('user')->order('create_time','DESC')->paginate();
        return $this->fetch('index',['list'=>$list]);
    }

    //删除会员(不启用)
    public function del()
    {
        if ($this->request->isPost()) {
            $param = $this->request->param();
            Db::table('user_log')->find($param['id']) && $this->error('你想干啥？');
            UserLogModel::destroy($param['id']);
            insert_admin_log('删除了用户日志');
            $this->success('删除成功');
        }
    }





}